#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, m;
ll a[N];
ll sum[N << 2], mx[N << 2];

void pushup(int p) {
  sum[p] = sum[p << 1] + sum[p << 1 | 1];
  mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
}
void build(int p, int l, int r) {
  if (l == r) {
    sum[p] = mx[p] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
void update(int L, int R, int p, int l, int r) {
  if (mx[p] == 1) return;
  if (l == r) {
    sum[p] = mx[p] = sqrt(mx[p]);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, p << 1, l, mid);
  if (R > mid) update(L, R, p << 1 | 1, mid + 1, r);
  pushup(p);
}
ll query(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return sum[p];
  int mid = (l + r) >> 1;
  ll res = 0;
  if (L <= mid) res += query(L, R, p << 1, l, mid);
  if (R > mid) res += query(L, R, p << 1 | 1, mid + 1, r);
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int cid = 0;
  while (cin >> n) {
    cid++;
    cout << "Case #" << cid << ":" << endl;
    rep(i, 1, n) cin >> a[i];
    build(1, 1, n);
    cin >> m;
    while (m--) {
      int op, l, r;
      cin >> op >> l >> r;
      if (l > r) swap(l, r);
      if (op == 0)
        update(l, r, 1, 1, n);
      else
        cout << query(l, r, 1, 1, n) << endl;
    }
    cout << endl;
  }
  return 0;
}